<?php use_helper('jQuery')?>

<div id="main_header" class="ui-widget-header ui-corner-all">
    <h3>Datos del Menú: "<?php echo $element->getTitle() ?>""</h3>
</div>
<div id="main_content" class="ui-widget ui-widget-content ui-corner-all">
    <table>
        <?php if($sf_user->hasCredential('Editar elemento')): ?>
            <tfoot>
                <tr>
                    <td colspan="2">
                         <?php echo jq_link_to_remote(
                                '<span class="ui-button-icon-primary ui-icon ui-icon-pencil"></span>
                                <span class="ui-button-text">Editar</span>',
                            array(
                                'update' => 'main',
                                'url' => url_for('element_edit',$element),
                                'before' => 'clearView();showLoaderMain();',
                                'complete' => 'hideLoader();',
                                'script' => true
                            ), array(
                                'class' => 'ui-button ui-widget ui-state-default ui-corner-all ui-button-text-icon-primary',
                                'title' => 'Editar'
                            )) ?>
                    </td>
                </tr>
            </tfoot>
        <?php endif; ?>
        <tbody>
            <?php if(!$element->getHeaderId() && !$element->getFooterId()) :?>
                <tr>
                    <th>Sección:</th>
                    <td>
                        <?php echo jq_link_to_remote(
                                $element->getSection(),
                            array(
                                'update' => 'main',
                                'url' => url_for('section_show',$element->getSection()),
                                'before' => 'clearView();showLoaderMain();',
                                'complete' => 'hideLoader();',
                                'script' => true
                            )) ?>
                    </td>
                </tr>
            <?php endif; ?>
            <tr>
                <th>Posición:</th>
                <td><?php echo $element->getPosition()?></td>
            </tr>
            <tr>
                <th>Orientación:</th>
                <td>
                    <?php if ($element->getMenu()->getIsVertical() == true): ?>
                        Vertical
                    <?php else: ?>
                        Horizontal
                    <?php endif; ?>
                </td>
            </tr>
            <?php if ($element->getMenu()->getIsVertical()): ?>
                <tr>
                    <th>Utiliza viñetas:</th>
                    <td>
                        <?php if ($element->getMenu()->getUsesBullet()): ?>
                            Si
                        <?php else: ?>
                            No
                        <?php endif; ?>
                    </td>
                </tr>
                <?php if ($element->getMenu()->getUsesBullet()): ?>
                    <tr>
                    <th>Viñeta:</th>
                    <?php if(!$element->getHeaderId() && !$element->getFooterId()) :?>
                        <td>
                            <img alt="<?php echo $element->getMenu()->getBullet() ?>"
                                 src="<?php echo '/uploads/portal_'.$element->getSection()->getPortalId().'/images/'.$element->getMenu()->getBullet() ?>"/>
                        </td>
                    <?php else: ?>
                        <td>
                            <img alt="<?php echo $element->getMenu()->getBullet() ?>"
                                 src="<?php echo '/uploads/portal_'.$element->getHeader()->getPortalId().'/images/'.$element->getMenu()->getBullet() ?>"/>
                        </td>
                    <?php endif; ?>
                </tr>
                <?php endif;?>
            <?php endif; ?>
            <tr>
                <th colspan="2">Numero de opciones: <?php echo $element->getMenu()->getOptions()->count()?></th>
            </tr>
            <tr>
                <td colspan="2">
                    <table>
                        <?php foreach ($element->getMenu()->getOptions() as $i=>$option):?>
                            <tr class="<?php echo ($i%2 ? 'odd' : 'even')?>">
                                <th>Tipo de Opción:</th>
                                <td>
                                    <?php if ($option->getIsLocal()): ?>
                                        Local
                                    <?php else: ?>
                                        Externa
                                    <?php endif; ?>
                                </td>
                            </tr>
                            <?php if ($option->getIsLocal()): ?>
                                <tr class="<?php echo ($i%2 ? 'odd' : 'even')?>">
                                    <th>Sección:</th>
                                    <td>
                                        <?php echo jq_link_to_remote(
                                            $option->getSection(),
                                            array(
                                                'update' => 'main',
                                                'url' => url_for('section_show',$option->getSection()),
                                                'before' => '$("#main").empty();showLoaderMain();',
                                                'complete' => 'hideLoader();',
                                                'script' => true
                                            )) ?>
                                    </td>
                                </tr>
                            <?php else: ?>
                                <tr class="<?php echo ($i%2 ? 'odd' : 'even')?>">
                                    <th>Opción:</th>
                                    <td><?php echo $option->getTitle()?></td>
                                </tr>
                                <tr class="<?php echo ($i%2 ? 'odd' : 'even')?>">
                                    <th>URL: </th>
                                    <td>
                                        <a href="<?php echo $option->getLink() ?>" target="_blank">
                                            <?php echo $option->getLink() ?>
                                        </a>
                                    </td>
                                </tr>
                            <?php endif; ?>
                        <?php endforeach;?>
                    </table>
                </td>
            </tr>
            <tr>
                <th>Publicado:</th>
                <td>
                    <?php if ($element->getPublished() == true): ?>
                        <img alt="Sí" src="/images/util/check.png">
                    <?php else: ?>
                        <img alt="No" src="/images/util/cross.png">
                    <?php endif; ?>
                </td>
            </tr>
            <tr>
                <th>Fecha de creación:</th>
                <td><?php echo $element->getDateTimeObject('created_at')->format('d/m/Y - g:i a') ?></td>
            </tr>
            <tr>
                <th><label>Ultima modificación:</label></th>
                <td><?php echo $element->getDateTimeObject('updated_at')->format('d/m/Y - g:i a') ?></td>
            </tr>
        </tbody>
    </table>
</div>